package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {


    /**
     * 向订单表中插入数据
     * */
    void insert(Orders orders);

    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);
    /**
     * 根据id查询订单信息
     * */
    @Select("select * from orders where id = #{id}")
    Orders getById(Long id);


    Page<Orders> page(OrdersPageQueryDTO orderPageQueryDTO);

    @Select("select count(status) from orders where status = #{status}")
    Integer countStatus(Integer status);

    @Select("select * from sky_take_out.orders where status =#{status} and order_time < #{localDateTime}")
    List<Orders> getStatusAndOrderTimeLT(Integer status, LocalDateTime localDateTime);

    Double sumByMap(Map map);

    /**
     * 动态查询每日订单数量
     * */
    String getOrderList(Map map);



    List<GoodsSalesDTO> getTop10(LocalDateTime beginTime, LocalDateTime endTime);

    Integer countByMap(Map map);
}
